// 云函数入口文件
const cloud = require('wx-server-sdk');
cloud.init();

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext();

  if (event.Content == 'help') {
    await cloud.openapi.customerServiceMessage.send({
      touser: wxContext.OPENID,
      msgtype: 'link',
      link: {
        title: '宗申.动力城已开通业主微信投票小程序...',
        description: '功能包括：签名发起、民调、投票、服务评价、问卷调查、资讯公告等',
        url: 'http://yz.2alive.cn/icon/toutiao.jpg',
        thumb_url: 'http://yz.2alive.cn/icon/toutiao.jpg'
      }
    });
  } else {
    await cloud.openapi.customerServiceMessage.send({
      touser: wxContext.OPENID,
      msgtype: 'text',
      text: {
        content: '您好,业主我当家很高兴为您服务！更多具体咨询请加微信沟通：13883166466'
      }
    });
  }

  return 'success';
};